package cc.bukkitPlugin.banitem.command.analyse;

import java.util.ArrayList;
import java.util.Arrays;

import org.bukkit.command.CommandSender;

import cc.bukkitPlugin.banitem.BanItem;
import cc.bukkitPlugin.banitem.CFG;
import cc.bukkitPlugin.banitem.command.AParamCommand;

public class ParamReason extends AParam{

    public ParamReason(BanItem pPlugin,AnalyseMan pAnalyor){
        super(pPlugin,pAnalyor);
        this.mLabels=new String[]{"r","reason"};
    }

    @Override
    public AnalyseResult handle(CommandSender pSender,AnalyseResult pCmdParam,String pArg){
        pCmdParam.mReason=pArg;
        return pCmdParam.buildSuccess();
    }

    @Override
    public ArrayList<String> getHelp(){
        ArrayList<String> help=new ArrayList<>();
        help.add(CFG.cmd_color+"  "+Arrays.toString(this.mLabels));
        help.add(CFG.help_color+"    设置配置的物品被禁用或拉黑的原因");
        return help;
    }

    @Override
    public ArrayList<String> tabComplete(CommandSender pSender,AParamCommand pCommand,String[] pArgs){
        ArrayList<String> list=new ArrayList<>();
        if(pArgs==null||pArgs.length==0)
            return list;
        String[] params=pArgs[pArgs.length-1].split(":",2);
        String tLabel=params[0]+":";
        if(params.length==2&&!params[1].isEmpty())
            return list;
        list.add(tLabel+"该物品不能使用");
        list.add(tLabel+"该物品已经禁用");
        return list;
    }

}
